home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 7
/
Aminet 7 - August 1995.iso
/
Aminet
/
comm
/
mail
/
mailchec.lha
/
mailcheck.s
< prev
Wrap
Text File
|
1995-04-15
|
10KB
|
555 lines
***************************************************
* MAILCHECK - pop up a requester if a file is hit!
*
* (c) Apr 15 1995 By C.H.Skilbeck
*
* Usage:
*
* 'run <>nil: mailcheck uumail:username (..uumail:username..etc)' (1st time)
* (can specify up to 16 filenames... any others ignored (silently...))
* or 'mailcheck off' to suspend checking
* or 'mailcheck on' to resume checking
* or 'mailcheck quit' to kill the mailchecker
*
* bugs/limitations:
*
* slaps a requester on front screen - even if it isn't public - HAVETHAT!
* doesn't stop notification requests when switched off, just doesn't requester
* just looks at first 2 chrs of args when sending messages to the daemon
* various memory leaks on some bombout conditions - fuck that!
* file(s) must exist at startup time
* error checking all a bit crap
*
*
*
*
***************************************************
; do multi file thing
opt c-,o+,ow-
incdir include:
include exec/nodes.i
include exec/ports.i
include exec/io.i
include dos/dos.i
include dos/notify.i
include req/reqbase.i
include hd:text/proto/lvo.offs
FrontScreen = 60
FirstWindow = 4
NRS = NotifyRequest_SIZEOF
***************************************************
main move.l a7,stak
clr.l dosbase
clr.l intbase
clr.l reqbase libs
clr.l gotport
clr.l gotreplyport ports
clr numbnuts
move d0,argc
move.l a0,argv args
bsr grabargs
lea taskport,a4 Add the message port
lea name,a5
bsr initport port found/created...?
tst.l d0
beq.s .firsttime
move.l d0,-(a7)
;reet - it's running already, check args for on,off,quit
lea replyname,a5
lea replyport,a4
bsr createport ;snaff up a reply port
st gotreplyport
;init a message,
move.l argptrs,a3
tst numargs
bne.s .kewl
lea soddingabout,a3
.kewl lea message,a0
move #MN_SIZE+2,MN_LENGTH(a0)
move.l #replyport,MN_REPLYPORT(a0)
move.b (a3)+,MN_SIZE(a0)
move.b (a3)+,MN_SIZE+1(a0)
;send the message
move.l 4.w,a6
move.l (a7)+,a0
lea message,a1
jsr LVO_PutMsg(a6)
;get the reply,
lea replyport,a0
jsr LVO_GetMsg(a6)
;knob off.
bra .bombout
;ELSE...
.firsttime st gotport
st telling
move.l 4.w,a6
lea intname,a1
moveq #0,d0
jsr LVO_OldOpenLibrary(a6)
MOVE.L D0,intbase
beq .bombout
MOVE.L 4.w,A6
LEA reqname,A1
MOVEQ #0,D0
jsr LVO_OldOpenLibrary(a6)
MOVE.L D0,reqbase
beq .bombout
move.l 4.w,a6
lea dosname,a1
jsr LVO_OldOpenLibrary(a6) Open dos, ALLRIGHT??~!?~
move.l d0,dosbase
beq .bombout
move.l d0,a6
jsr LVO_Output(a6)
move.l d0,stdout
tst numargs
bne.s .okmanf
lea usage,a4
bsr treq
bra .bombout
.okmanf ;scan through args list of filenames...?
move numargs,d7
subq #1,d7
lea argptrs,a5
lea notifyreq,a4
lea namebuf,a3
.gogocheckfilenames movem.l d7/a3-a5,-(a7)
move.l dosbase,a6
move.l (a5),d1
move.l #MODE_OLDFILE,d2 open file
jsr LVO_Open(a6)
move.l d0,handle
bne.s .swff no such file!?!?!
lea flerr,a4
bsr treq
bra .bombout
.swff ;stash off full name in list of full names
move.l d0,d1
move.l a3,d2
move.l #256,d3
jsr LVO_NameFromFH(a6) get file's full name..
move.l handle,d1
jsr LVO_Close(a6) close it
;OK, bang up 1 notify per file name
move.l a4,a0
moveq #NRS-1,d7 clear the shitty noti
.clrn clr.b (a0)+
dbra d7,.clrn
move.l a4,a0
move.l a3,nr_Name(a0) ;wot file
move.l a3,nr_FullName(a0)
move.l #taskport,nr_Port(a0)
move.l #9,nr_Flags(a0) ;msg, and wait for reply
; Start 1 for each file
move.l a0,d1
jsr LVO_StartNotify(a6) ;start notificationness....
;******** HMMMMMMMMMMM ? STRESS.........
tst.l d0
beq .bombout ;ok?
movem.l (a7)+,d7/a3-a5
.skippy tst.b (a3)+
bne.s .skippy
lea NRS(a4),a4 next notify
addq.w #4,a5
addq #1,numbnuts
dbra d7,.gogocheckfilenames
;wait for it to get hit (or a BREAK signal...)
lea taskport,a0
moveq #0,d0
move.b MP_SIGBIT(a0),d0
moveq #1,d1
lsl.l d0,d1
bset #12,d1 CTRL_C sigbit
move.l d1,signalset
;********************************************
;MAIN TASK PORT WAIT MESSAGE LOOP BIT THING
;********************************************
.wait move.l 4.w,a6
move.l signalset,d0
jsr LVO_Wait(a6)
;got one! break or notify?
btst #12,d0
bne .reetquit ;ctrl - c quits it
;get message to ident file
move.l 4.w,a6
lea taskport,a0
jsr LVO_GetMsg(a6)
tst.l d0
beq.s .wait
move.l d0,-(a7)
move.l d0,a0 ;OK, size check??
move MN_LENGTH(a0),d0
cmp #MN_SIZE+2,d0
bne.s .notif
move.b MN_SIZE(a0),d0 ;snaff the message!
and.b #223,d0
lsl #8,d0
move.b MN_SIZE+1(a0),d0
and.b #223,d0
cmp #'OI',d0
beq.s .sodding
cmp #'ON',d0
beq.s .turnon
cmp #'OF',d0
beq.s .turnoff
cmp #'QU',d0
beq.s .quitter
.sodding lea soddingabout,a4
bsr treq
bra .waitloop
.turnon st telling
bra .waitloop
.turnoff sf telling
bra .waitloop
.quitter addq.w #4,a7
.reetquit lea tellquit,a4
bsr treq
bra .mainexit0
;tell which file
.notif tst.b telling
beq.s .waitloop unless it's switched off
lea textbuffer,a2
lea tell,a1
.cpy0 move.b (a1)+,d0
beq.s .cc
move.b d0,(a2)+
bra.s .cpy0
.cc move.l nm_NReq(a0),a0
move.l nr_FullName(a0),a0
.cpy1 move.b (a0)+,d0
beq.s .cc1
move.b d0,(a2)+
bra.s .cpy1
.cc1 clr.b (a2)+
lea textbuffer,a4
bsr treq
.waitloop move.l 4.w,a6
move.l (a7)+,a1
jsr LVO_ReplyMsg(a6) cheers
bra .wait
***************************************************
.mainexit0 move numbnuts,d7
subq #1,d7
lea notifyreq,a5
.killem move.l a5,d1
move.l dosbase,a6
jsr LVO_EndNotify(a6) ditch ALL the notifies
lea NRS(a5),a5
dbra d7,.killem
.bombout move.l stak,a7
move.l 4.w,a6
tst.l gotreplyport
beq.s .no
lea replyport,a1 ditch reply port
bsr ditchport
.no tst.l gotport
beq.s .no1
lea taskport,a1
bsr ditchport ditch task port
.no1 move.l 4.w,a6
move.l dosbase,d0
beq.s .nod
move.l d0,a1
jsr LVO_CloseLibrary(a6)
.nod move.l intbase,d0
beq.s .nod1
move.l d0,a1
jsr LVO_CloseLibrary(a6)
.nod1 move.l reqbase,d0
beq.s .nod2
move.l d0,a1
jsr LVO_CloseLibrary(a6)
.nod2
moveq #0,d0
rts
***************************************
* Find the message port or create it
initport move.l 4.w,a6
jsr LVO_Forbid(a6) !
lea name,a1
jsr LVO_FindPort(a6) ...
move.l d0,-(a7)
jsr LVO_Permit(a6) ?
move.l (a7)+,d0
beq.s createport
rts ; if d0 != 0, then it's the port!
createport bsr getsignal grab a signal bit
move.l d0,-(a7)
move.l a4,a1
moveq #7,d7
.gg clr.l (a1)+
dbra d7,.gg
move.l 4.w,a6
sub.l a1,a1
jsr LVO_FindTask(a6)
move.l d0,MP_SIGTASK(a4)
move.l (a7)+,d0
move.b d0,MP_SIGBIT(a4)
move.l a5,LN_NAME(a4)
move.b #5,LN_PRI(a4)
move.b #NT_MSGPORT,LN_TYPE(a4)
move.l a4,a1
jsr LVO_AddPort(a6) Add the Port
moveq #0,d0
rts
*** Grab a signal bit
getsignal move.l 4.w,a6
moveq #-1,d0
jsr LVO_AllocSignal(a6)
rts
ditchport moveq #0,d0
move.b MP_SIGBIT(a1),d0
move.l d0,-(a7)
jsr LVO_RemPort(a6)
move.l (a7)+,d0
jsr LVO_FreeSignal(a6) Free the signal bit
rts
*** compare strings at a0,a1 (uppercase them)
strcmp move.b (a0)+,d0
move.b (a1)+,d1
beq.s .yes
and #224,d0
cmp.b d0,d1
beq.s strcmp
moveq #0,d0
rts
.yes moveq #-1,d0
rts
** DO a shitty text request!
treq move.l intbase,a6
lea trq,a2
move.l FrontScreen(a6),a3
move.l FirstWindow(a3),d3 front screen, or 0
move.l d3,TR_Window(a2)
clr.l TR_MiddleText(a2)
clr.l TR_PositiveText(a2)
clr.l TR_NegativeText(a2)
move.l #knobmsg,TR_NegativeText(a2)
move.l #knobmsg1,TR_PositiveText(a2)
move #1,TR_TextColor(a2)
move.l a4,TR_Text(a2)
clr.l TR_Controls(a2)
move #AMIGAKEYS,TR_KeyMask(a2)
move.l #title,TR_Title(a2)
move.l reqbase,a6
move.l a2,a0
jsr LVO_TextRequest(a6)
rts
**************************************************
*
* GRABARGS :
* numargs : how many words...
* argptrs : numargs pointers into
* args : safely stashed bytes (null termed...)
grabargs move.l argv,a0
move argc,d0
lea args,a1
lea argptrs,a2
clr.b (a1)
clr.l (a2)
move #254,d6
moveq #0,d7
subq #2,d0
bmi.s .exit
.nxtarg cmp #16,d7
bge.s .exit
addq #1,d7
move.l a1,(a2)+ got an arg ! stash ptr
move.b #' ',d5
cmp.b #'"',(a0)
bne.s .grabarg
addq.l #1,a0
dbra d0,.go
clr.b (a1)
bra.s .exit
.go move.b #'"',d5
.grabarg move.b (a0)+,d1 getchr
cmp.b d5,d1 =' '? (or '"')
beq.s .gots
move.b d1,(a1)+ no,stashit
subq #1,d6
bmi.s .fullup
dbra d0,.grabarg next
.fullup clr.b (a1)
bra.s .exit
.gots clr.b (a1)+
.tst cmp.b #' ',(a0)
beq.s .skippy
cmp.b #9,(a0)
beq.s .skippy
dbra d0,.nxtarg
bra.s .exit
.skippy addq.w #1,a0
dbra d0,.tst
.exit move d7,numargs
rts
***************************************************
section blab,data
dosname dc.b "dos.library",0
reqname dc.b "req.library",0
intname dc.b "intuition.library",0
name dc.b "MAILCHECK_PORT",0
replyname dc.b "MAILCHECK_REPLY_PORT",0
title dc.b "MailCheck v1.0 (c) 1995 CHS",0
tell dc.b "File has been hit :",0
tellquit dc.b "Mailcheck sodding off, allreeeet?",0
soddingabout dc.b "OI! Stop sodding about, you fool!",0
usage dc.b "Specify filename(s) and stop cunting about",0
knobmsg dc.b "Have that!",0
knobmsg1 dc.b "Have this!",0
flerr dc.b "One or more of those files are not there, dickcheese..",0
***************************************************
section crap,bss
notifyreq ds.b NotifyRequest_SIZEOF*16 some notify requests
signalset ds.l 1 signals to watch
gotport ds.l 1 got a taskport?
gotreplyport ds.l 1 got a replyport?
numbnuts ds.w 1 how many requests requested
namebuf ds.b 1024 filenames
handle ds.l 1 filehandles
stdout ds.l 1
stak ds.l 1
dosbase ds.l 1
intbase ds.l 1
reqbase ds.l 1
telling ds.b 4 switched on or off?
numargs ds.w 1
args ds.b 256
argptrs ds.l 16
argc ds.w 1
argv ds.l 1
textbuffer ds.b 256 for messages
trq ds.b TR_SIZEOF*8
message ds.b MN_SIZE+2 4 byte message
taskport ds.b MP_SIZE the main port
replyport ds.b MP_SIZE a little reply one
***************************************************
end